package com.kexuexiong.demo.bear.common.multiDataSource;

import com.alibaba.ttl.TransmittableThreadLocal;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class DataSourceContextHolder {

    private static final TransmittableThreadLocal<String> CONTEXT = new TransmittableThreadLocal<>();


    public static String getDataSourceContext() {
        return CONTEXT.get();
    }

    public static void cleanContext() {
        log.debug("清除数据源CONTEXT：{}",getDataSourceContext());
        CONTEXT.remove();
    }

    public static void setContext(String dataSourceName) {
        CONTEXT.set(dataSourceName);
    }

}
